const pages = import.meta.glob(['@/common/**/*.vue', '!/**/components/**/*.vue']);
const routerPage = [];
Object.entries(pages).forEach(([filePath]) => {
  const keys = filePath
    .replace(/\/src\/common/, '')
    .replace(/\.(vue|js)$/, '')
    .replace(/\{2,}/g, '/')
    .split('/')
    .slice(1);
  let name = '';
  let path = '';
  keys.forEach((key) => {
    name = name ? name + '-' + key.replace('_', '') : key.replace('_', '');
    name += key === '_' ? 'all' : '';
    if (key === 'index' && !path) {
      path += '/';
    } else {
      path += '/' + (key === '_' ? '*' : key.replace('_', ''));
      if (key !== '_' && key.indexOf('_') !== -1) {
        path += '?';
      }
    }
  });
  const route = {
    name,
    path,
    component: pages[`/src/common${path}.vue`]
  };
  routerPage.push(route);
});
export default routerPage;
